package com.imooc.sellspringcloud.server.mq;

import com.imooc.sellspringcloud.server.dto.OrderDTO;
import com.imooc.sellspringcloud.server.redis.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author
 * @create 2019-08-07 21:45
 **/
@Service
@Slf4j
public class ProductMessage {

    @Autowired
    RabbitTemplate rabbitTemplate;

    public void sendOrder(OrderDTO orderDTO){
        String message = RedisService.beanToString(orderDTO);
        log.info("send message {}", message);
        rabbitTemplate.convertAndSend("create-order-exchange",
                "createOrderKey",message);
    }

}